PROTO_SRC = ../proto/user/user.proto
PROTO_OUT = ./
# 默认的数据库连接
DB_URL = "root:zhan@tcp(127.0.0.1:3306)/test"

user:
	protoc --proto_path=../proto --go_out=$(PROTO_OUT) --go-grpc_out=$(PROTO_OUT) $(PROTO_SRC)

mysql_all:
	goctl model mysql datasource -url=$(DB_URL) -table="*" -dir="./model"

# mysql_table 规则接收一个表名作为参数
mysql_table:
	@if [ -z "$(t)" ]; then \
		echo "Error: TABLE parameter is missing. Please specify the table name."; \
		exit 1; \
	else \
		echo "Generating model for table $(t)..."; \
		goctl model mysql datasource -url=$(DB_URL) -table="$(t)" -dir="./model"; \
	fi
